// 数据生成器API服务

import axios from 'axios'
import type { 
  DataGeneratorConfig, 
  GeneratorTask, 
  FieldTypesResponse, 
  StartTaskResponse 
} from '@/types/dataGenerator'

const API_BASE = '/api/data-generator'

export const dataGeneratorApi = {
  // 获取支持的字段类型
  getFieldTypes: async (): Promise<FieldTypesResponse> => {
    const response = await axios.get(`${API_BASE}/field-types`)
    return response.data
  },

  // 启动数据生成任务
  startGeneration: async (config: DataGeneratorConfig): Promise<StartTaskResponse> => {
    const response = await axios.post(`${API_BASE}/start`, config)
    return response.data
  },

  // 获取当前任务状态
  getCurrentStatus: async (): Promise<any> => {
    const response = await axios.get(`${API_BASE}/status`)
    return response.data
  },

  // 停止当前任务
  stopCurrentTask: async (): Promise<{ message: string }> => {
    const response = await axios.post(`${API_BASE}/stop`)
    return response.data
  }
}
